package Kuang;

/**
 * description:静态代理
 * author:zcx
 * lenovo
 * 时间：2022.02.08.20.40
 */
public class Demo6 {
    public static void main(String[] args) {
        new Thread(()->{
            System.out.println("我爱你");
        }).start();
        new WeddingCompang(new You()).HappyMarry();
        var wed=new WeddingCompang(new You());
        wed.HappyMarry();

    }
}
interface Marry{
    void HappyMarry();
}
//真实角色
class You implements Marry{
    @Override
    public void HappyMarry() {
        System.out.println("结婚");
    }
}
//代理角色，帮助你结婚
class WeddingCompang implements Marry{
    private Marry target;
public WeddingCompang(Marry target){
    this.target=target;
}
    @Override
    public void HappyMarry() {
       before();
       this.target.HappyMarry();
       after();
    }
    private void before(){
        System.out.println("结婚之前,布置现场");
    }
    private void after(){
        System.out.println("结婚之后，收尾款");
    }
}
